#!/usr/bin/python
# -*- encoding: utf-8 -*-
'''
@File    :   9.py
@Time    :   2020/03/15 19:43:34
@Author  :   Malygos_l 
@Version :   1.0
@Contact :   751756061@qq.com
@WebSite :   www.gitee.com/malygos_l
'''
# Start typing your code from here
# 设计一个猜数字 游戏；最多只能猜测N次，在N次之内猜不出，就退出程序，提示猜测失败;

from random import randint

out_time = 4
num = randint(0,20)
guess_time = 0
input_num = input('你可以猜{0}次,请输入你所猜的数字：'.format(out_time))
while guess_time<out_time:
    input_num = int(input_num)
    if input_num == num:
        print('猜对了')
        break
    elif input_num < num:
        print("小了")
        guess_time += 1
    elif input_num > num:
        print("大了")
        guess_time += 1
        
    if guess_time == out_time:
        print("猜测失败")
        break
    input_num = input("请输入你所猜的数字：")